package com.xike.micromemberserver.config;//package com.woniuxy.micromember.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import io.seata.rm.datasource.DataSourceProxy;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
//import javax.sql.DataSource;
//
///**
// * Auther: wuson  <br/>
// * Date: 2021/3/16:10:26  <br/>
// * Description:
// */
//@Configuration
//public class SeataConfiguration {
//    /**
//     * 数据源
//     * @return
//     */
//    @Bean
//    @ConfigurationProperties(prefix = "spring.datasource")
//    public DataSource druidDataSource(){
//        DruidDataSource druidDataSource = new DruidDataSource();
//        return druidDataSource;
//    }
//    /**
//     * 设置数据源代理对象
//     * 指定名字为dataSource
//     * @Primary 优先使用
//     * @param druidDataSource
//     * @return
//     */
//    @Bean("dataSource")
//    @Primary
//    public DataSourceProxy dataSource(DataSource druidDataSource){
//        return new DataSourceProxy(druidDataSource);
//    }
//    /**
//     * 产生SqlSessionFactory工厂
//     * @param dataSource
//     * @return
//     * @throws Exception
//     */
//    @Bean
//    public SqlSessionFactory sqlSessionFactory(DataSourceProxy dataSource)throws Exception{
//        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//        //设置数据源   javax.sql.DataSource
//        sqlSessionFactoryBean.setDataSource(dataSource);
//        //加载mapper文件
//        sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver()
//                .getResources("classpath*:/mapper/*.xml"));
//        //设置事务工厂，用于创建事务
//        sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory());
//        sqlSessionFactoryBean.setTypeAliasesPackage("com.woniuxy.micromember.bean");
//        //创建工厂对象
//        return sqlSessionFactoryBean.getObject();
//    }
//}